package com.kmgames.ballsinholes.scene;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.math.Vector2;
import com.kmgames.ballsengine.rendering.Renderer;
import com.kmgames.ballsengine.scene.Scene;
import com.kmgames.ballsinholes.models.BallModel;
import com.kmgames.ballsinholes.models.BottomSquareModel;

public class BallsInHolesScene extends Scene {
	public BallsInHolesScene(Renderer renderer) {
		super(renderer);

		AddModel(new BottomSquareModel(worldManager));

		BallModel ball = new BallModel(worldManager);
		ball.getPosition().z = 0.04f;
		AddModel(ball);
	}

	@Override
	public void render() {
		worldManager.setGravity(new Vector2(2 * Gdx.input.getAccelerometerY(),
				-2 * Gdx.input.getAccelerometerX()));
		super.render();
	}

	public void updateCamera(int width, int height) {
		camera = new PerspectiveCamera(67, width, height);
		camera.position.set(0, 0, 2);
		camera.lookAt(0, 0, 0);
		camera.near = 0.1f;
		camera.far = 1000;
		camera.update();
	}
}
